//package org.example.test3;
//
//import io.netty.handler.codec.http.HttpResponseStatus;
//import reactor.core.publisher.Mono;
//import reactor.netty.http.server.HttpServer;
//import reactor.netty.http.server.HttpServerRequest;
//import reactor.netty.http.server.HttpServerResponse;
//import reactor.netty.http.server.HttpServerRoutes;
//
//public class WebServer {
//    public static void main(String[] args) {
//        HttpServer.create()
//                .port(8080)
//                .route(WebServer::configureRoutes)
//                .bindNow()
//                .onDispose()
//                .block();
//    }
//
//    private static void configureRoutes(HttpServerRoutes routes) {
//        routes.get("/hello", WebServer::handleHello);
//        routes.post("/user", WebServer::handleCreateUser);
//    }
//
//    private static Mono<Void> handleHello(HttpServerRequest request, HttpServerResponse response) {
//        // 构造响应内容
//        return response.sendString(Mono.just("Hello, World!").map(
//                s -> response.newChunkedResponse(
//                        HttpResponseStatus.OK, () -> Mono.just(response
//                        .headers()
//                        .set("Content-Type", "text/plain")), (o, output) ->
//                        output.sendString(Mono.just(s))).then()));
//    }
//
//    private static Mono<Void> handleCreateUser(HttpServerRequest request, HttpServerResponse response) {
//        return request.receive()
//                .aggregate()
//                .asString()
//                .flatMap(payload -> {
//                    // 解析请求体中的用户信息并创建用户
//                    // TODO: 处理创建用户的逻辑
//
//                    // 返回创建的用户信息
//                    return response.status(HttpResponseStatus.CREATED)
//                            .header("Content-Type", "text/plain")
//                            .sendString(Mono.just("User created successfully"));
//                });
//    }
//}
